<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>webpack | mozihao</title><meta name="keywords" content="mozihao github"><meta name="author" content="mozihao"><meta name="copyright" content="mozihao"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="webpack为什么使用webpack webpack基础用法webpack默认配置文件： webpack.config.js 可以通过webpack –config指定配置文件 123456789101112131415module.exports &#x3D; &amp;#123;	entry: &#39;.&#x2F;src&#x2F;index.js1&#39;,	output: &#39;.&amp;#">
<meta property="og:type" content="article">
<meta property="og:title" content="webpack">
<meta property="og:url" content="https://mo_zi_hao.gitee.io/blog/posts/15318/index.html">
<meta property="og:site_name" content="mozihao">
<meta property="og:description" content="webpack为什么使用webpack webpack基础用法webpack默认配置文件： webpack.config.js 可以通过webpack –config指定配置文件 123456789101112131415module.exports &#x3D; &amp;#123;	entry: &#39;.&#x2F;src&#x2F;index.js1&#39;,	output: &#39;.&amp;#">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/745.jpg">
<meta property="article:published_time" content="2021-08-29T15:22:14.598Z">
<meta property="article:modified_time" content="2021-08-29T15:22:14.598Z">
<meta property="article:author" content="mozihao">
<meta property="article:tag" content="mozihao github">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/745.jpg"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://mo_zi_hao.gitee.io/blog/posts/15318/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-08-29 23:22:14'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><link rel="stylesheet" type="text/css" href="./css/iconfont.css" media="all"><meta name="generator" content="Hexo 5.4.2"><link rel="alternate" href="/blog/atom.xml" title="mozihao" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/%E6%B5%B7%E8%B4%BC008.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">24</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">16</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 前端知识思维导图</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/mo_zi_hao/picsBed/raw/master/image/745.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">mozihao</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 前端知识思维导图</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">webpack</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-08-29T15:22:14.598Z" title="发表于 2021-08-29 23:22:14">2021-08-29</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-08-29T15:22:14.598Z" title="更新于 2021-08-29 23:22:14">2021-08-29</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/webpack/">webpack</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="webpack"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="webpack"><a href="#webpack" class="headerlink" title="webpack"></a>webpack</h2><h2 id="为什么使用webpack"><a href="#为什么使用webpack" class="headerlink" title="为什么使用webpack"></a>为什么使用webpack</h2><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410172005469.png" alt="image-20210410172005469"></p>
<h2 id="webpack基础用法"><a href="#webpack基础用法" class="headerlink" title="webpack基础用法"></a>webpack基础用法</h2><p>webpack默认配置文件： webpack.config.js</p>
<p>可以通过webpack –config指定配置文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">module.exports &#x3D; &#123;</span><br><span class="line">	entry: &#39;.&#x2F;src&#x2F;index.js1&#39;,</span><br><span class="line">	output: &#39;.&#x2F;dist&#x2F;main.js&#39;,</span><br><span class="line">	mode: &#39;production&#39;,</span><br><span class="line">	module:&#123;</span><br><span class="line">		rule:[</span><br><span class="line">			&#123;test:&#x2F;\.txt$&#x2F;,use:&#39;raw-loader&#39;&#125;</span><br><span class="line">		]</span><br><span class="line">	&#125;,</span><br><span class="line">	plugins:[</span><br><span class="line">		new HtmlwebpackPlugin(&#123;</span><br><span class="line">			template: &#39;.&#x2F;src&#x2F;index.html&#39;</span><br><span class="line">		&#125;)</span><br><span class="line">	]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>环境搭建：</p>
<p>创建空目录和package.json</p>
<ul>
<li>mkdir my-project</li>
<li>cd my-project</li>
<li>npm init -y</li>
</ul>
<p>安装webpack和webpack-cli</p>
<ul>
<li>npm install webpack webpack-cli –save-dev</li>
<li>检查是否安装成功：./node_module/.bin/webpack -v</li>
</ul>
<p>打包</p>
<ul>
<li><p>package.json默认可以读取到.bin目录下的命令</p>
</li>
<li><p>在package.json的script指定webpack命令即可</p>
</li>
</ul>
<h3 id="entry："><a href="#entry：" class="headerlink" title="entry："></a>entry：</h3><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410174613090.png" alt="image-20210410174613090"></p>
<h3 id="ouput"><a href="#ouput" class="headerlink" title="ouput"></a>ouput</h3><p>如果使用多个入口的话多个js文件，output通过占位符确保文件名称的唯一</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">moudle.exports &#x3D; &#123;</span><br><span class="line">	entry:&#123;</span><br><span class="line">		index: &#39;.&#x2F;src&#x2F;index.js&#39;,</span><br><span class="line">		search: &#39;.&#x2F;src&#x2F;search.js&#39;</span><br><span class="line">	&#125;,</span><br><span class="line">	output:&#123;</span><br><span class="line">		filename: [name].js,  &#x2F;&#x2F;通过占位符确保文件名称唯一</span><br><span class="line">		path: __dirname + &#39;&#x2F;dist&#39;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h3 id="loader"><a href="#loader" class="headerlink" title="loader"></a>loader</h3><p>loader都放在module里面</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410180138171.png" alt="image-20210410180138171"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410181512152.png" alt="image-20210410181512152"></p>
<h4 id="babel"><a href="#babel" class="headerlink" title="babel"></a>babel</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410182631440.png" alt="image-20210410182631440"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">moudle.exports &#x3D; &#123;</span><br><span class="line">	entry:&#123;</span><br><span class="line">		index: &#39;.&#x2F;src&#x2F;index.js&#39;,</span><br><span class="line">		search: &#39;.&#x2F;src&#x2F;search.js&#39;</span><br><span class="line">	&#125;,</span><br><span class="line">	output:&#123;</span><br><span class="line">		filename: [name].js,  &#x2F;&#x2F;通过占位符确保文件名称唯一</span><br><span class="line">		path: __dirname + &#39;&#x2F;dist&#39;</span><br><span class="line">	&#125;,</span><br><span class="line">	mode:&#39;production&#39;,</span><br><span class="line">	module:&#123;</span><br><span class="line">		rules:&#123;</span><br><span class="line">			test: &#x2F;.js$&#x2F;,</span><br><span class="line">			use: &#39;bebel-loader&#39;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p>根目录创建.babelrc文件</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410182800396.png" alt="image-20210410182800396"></p>
<h4 id="css"><a href="#css" class="headerlink" title="css"></a>css</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410184758265.png" alt="image-20210410184758265"></p>
<p>解析Less，SaSS，下面以Less为例</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410185433679.png" alt="image-20210410185433679"></p>
<h4 id="解析图片字体"><a href="#解析图片字体" class="headerlink" title="解析图片字体"></a>解析图片字体</h4><h5 id="file-loader"><a href="#file-loader" class="headerlink" title="file-loader"></a>file-loader</h5><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410190142551.png" alt="image-20210410190142551"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410190057373.png" alt="image-20210410190057373"></p>
<h5 id="url-loader-和file-loader差不多，内部也是用了file-loader"><a href="#url-loader-和file-loader差不多，内部也是用了file-loader" class="headerlink" title="url-loader(和file-loader差不多，内部也是用了file-loader)"></a>url-loader(和file-loader差不多，内部也是用了file-loader)</h5><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410190822600.png" alt="image-20210410190822600"></p>
<h3 id="plugin"><a href="#plugin" class="headerlink" title="plugin"></a>plugin</h3><p>插件用于bundle文件的优化，资源管理和环境变量注入</p>
<p>作用于整个构建过程</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410181948158.png" alt="image-20210410181948158"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410182213154.png" alt="image-20210410182213154"></p>
<h3 id="mode"><a href="#mode" class="headerlink" title="mode"></a>mode</h3><p>Mode用来指定当前的构建环境是：production、development还是none</p>
<p>设置mode可以使用webpack内置的函数，默认值是prodution</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410182424084.png" alt="image-20210410182424084"></p>
<h3 id="webpack中的文件监听"><a href="#webpack中的文件监听" class="headerlink" title="webpack中的文件监听"></a>webpack中的文件监听</h3><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410191327307.png" alt="image-20210410191327307"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410191359139.png" alt="image-20210410191359139"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410191842641.png" alt="image-20210410191842641"></p>
<h3 id="热更新"><a href="#热更新" class="headerlink" title="热更新"></a>热更新</h3><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410211842421.png" alt="image-20210410211842421"></p>
<p>在webpack.config.js中配置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">const path &#x3D; require(&#39;path&#39;)</span><br><span class="line">const webpack &#x3D; require(&#39;webpack&#39;)  &#x2F;&#x2F; + </span><br><span class="line">module.exports &#x3D; &#123;</span><br><span class="line">	entry: &#39;.&#x2F;src&#x2F;index.js&#39;,</span><br><span class="line">	output:&#123;</span><br><span class="line">		filename: [name].js,</span><br><span class="line">		path: __dirname + &#39;&#x2F;dist&#39;</span><br><span class="line">	&#125;,</span><br><span class="line">	modules:[],</span><br><span class="line">	mode: &#39;development&#39;，   &#x2F;&#x2F;development模式</span><br><span class="line">	plugins:[</span><br><span class="line">		new webpack.HtModuleReplacementPlugin() &#x2F;&#x2F; + 热更新为webpack内置</span><br><span class="line">	]，</span><br><span class="line">	devServer: &#123;   &#x2F;&#x2F;  +</span><br><span class="line">		contentBase: &#39;.&#x2F;dist&#39;,  &#x2F;&#x2F;服务基础目录</span><br><span class="line">		hot: true</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410213433295.png" alt="image-20210410213433295"></p>
<h3 id="文件指纹策略"><a href="#文件指纹策略" class="headerlink" title="文件指纹策略"></a>文件指纹策略</h3><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410225339498.png" alt="image-20210410225339498"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410230423227.png" alt="image-20210410230423227"></p>
<p>一般我们图片的文件指纹使用hash，js使用Chunkhash，而css使用Contenthash</p>
<p>下面跟着hash，Chunkhash，Contenthash后面的8为设置指纹的长度</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410230653119.png" alt="image-20210410230653119"></p>
<p><code>注意</code>：css的文件指纹需要使用MiniCssExtractPlugin这个插件，还需把插件的loader加进去，插件是把css提取成一个独立的文件，是没办法和style loader一起使用的，因为他们之间的功能是互斥的，因为style loader是把样式插入到header里面，而这个插件是把样式提取出来，如果你想要用这个插件把css文件提取出来，那么就要把style loader删掉替换成MiniCssExtractPlugin.loader</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410230737620.png" alt="image-20210410230737620"></p>
<h3 id="代码压缩"><a href="#代码压缩" class="headerlink" title="代码压缩"></a>代码压缩</h3><h4 id="js文件的压缩"><a href="#js文件的压缩" class="headerlink" title="js文件的压缩"></a>js文件的压缩</h4><p>webpack4后就内置了uglifyjs-webpack-plugin，当然你也可以手动安装这个插件设置一些额外的参数，比如可以开启他默认并行压缩</p>
<h4 id="CSS文件的压缩"><a href="#CSS文件的压缩" class="headerlink" title="CSS文件的压缩"></a>CSS文件的压缩</h4><p>是要安装optimize-css-assets-webpack-plugin 和 cssnano一起使用</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410233302143.png" alt="image-20210410233302143"></p>
<h4 id="html文件压缩"><a href="#html文件压缩" class="headerlink" title="html文件压缩"></a>html文件压缩</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210410233422926.png" alt="image-20210410233422926"></p>
<h4 id="打包文件删除"><a href="#打包文件删除" class="headerlink" title="打包文件删除"></a>打包文件删除</h4><p>如果不删除文件数量会增加的</p>
<h5 id="手动删除"><a href="#手动删除" class="headerlink" title="手动删除"></a>手动删除</h5><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210411002236433.png" alt="image-20210411002236433"></p>
<h5 id="使用插件删除"><a href="#使用插件删除" class="headerlink" title="使用插件删除"></a>使用插件删除</h5><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210411153447997.png" alt="image-20210411153447997"></p>
<h4 id="自动补全css前缀"><a href="#自动补全css前缀" class="headerlink" title="自动补全css前缀"></a>自动补全css前缀</h4><p>需要安装postcss-loader插件和autoprefixer插件</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210411160241704.png" alt="image-20210411160241704"></p>
<h4 id="移动端css-px自动转换成rem"><a href="#移动端css-px自动转换成rem" class="headerlink" title="移动端css px自动转换成rem"></a>移动端css px自动转换成rem</h4><p>需要安装px2rem-loader和lib-flexible插件</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210411161025254.png" alt="image-20210411161025254"></p>
<h4 id="资源内联"><a href="#资源内联" class="headerlink" title="资源内联"></a>资源内联</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412224455165.png" alt="image-20210412224455165"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412224423120.png" alt="image-20210412224423120"></p>
<p>安装raw-loader的0.5.1的版本</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm i raw-loader@0.5.1 -D</span><br></pre></td></tr></table></figure>

<p>上面内联的html</p>
<p>因为我们使用的是html-webpack-plugin，默认的模板引擎是ejs的模板引擎，所以我们上面使用的是ejs的语法</p>
<h4 id="css内联"><a href="#css内联" class="headerlink" title="css内联"></a>css内联</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412224846701.png" alt="image-20210412224846701"></p>
<h4 id="多页面打包"><a href="#多页面打包" class="headerlink" title="多页面打包"></a>多页面打包</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412225836153.png" alt="image-20210412225836153"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412230021681.png" alt="image-20210412230021681"></p>
<p>先安装glod这个库</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm i glob -D</span><br></pre></td></tr></table></figure>

<p>然后在我们的webpack.config.js文件配置</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> glob = <span class="built_in">require</span>(<span class="string">&#x27;glob&#x27;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> setMPA = <span class="function">()=&gt;</span>&#123;</span><br><span class="line">	<span class="keyword">const</span> entry = &#123;&#125;;</span><br><span class="line">	<span class="keyword">const</span> htmlWebpackPlugins = [];</span><br><span class="line">	<span class="keyword">const</span> entryFiles = glob.sync(path.join(__dirname,<span class="string">&#x27;./src/*/index.js&#x27;</span>))</span><br><span class="line">    <span class="built_in">Object</span>.keys(entryFiles).map(<span class="function">(<span class="params">index</span>)=&gt;</span>&#123;</span><br><span class="line">        <span class="keyword">const</span> entryFile = entryFiles[index]</span><br><span class="line">        <span class="keyword">const</span> match = entryFile.match(<span class="regexp">/src\/(.*)\/index\.js/</span>);</span><br><span class="line">        <span class="keyword">const</span> pageName = match &amp;&amp; match[<span class="number">1</span>];</span><br><span class="line">        entry[pageName] = entryFile;</span><br><span class="line">        htmlWebpackPlugins.push(</span><br><span class="line">        	<span class="keyword">new</span> HtmlWebpackPlugin(&#123;</span><br><span class="line">                template: path.join(__dirname,<span class="string">`src/<span class="subst">$&#123;pageName&#125;</span>/index.html`</span>),</span><br><span class="line">                filename: <span class="string">`<span class="subst">$&#123;pageName&#125;</span>.html`</span>,</span><br><span class="line">				chunks: [pageName],</span><br><span class="line">				inject: <span class="literal">true</span>,</span><br><span class="line">				minify: &#123;</span><br><span class="line">					html5: <span class="literal">true</span>,</span><br><span class="line">            		collapseWhitespace: <span class="literal">true</span>,</span><br><span class="line">            		preserveLineBreaks: <span class="literal">false</span>,</span><br><span class="line">            		minifyCSS: <span class="literal">true</span>,</span><br><span class="line">            		minifyJS: <span class="literal">true</span>,</span><br><span class="line">            		removeComments: <span class="literal">false</span></span><br><span class="line">				&#125;</span><br><span class="line">            &#125;)</span><br><span class="line">        )</span><br><span class="line">    &#125;)</span><br><span class="line">	<span class="keyword">return</span> &#123;</span><br><span class="line">		enrty,</span><br><span class="line">		htmlWebpackPlugins</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> &#123;entry,htmlWebpackPlugins&#125; = setMPA();</span><br><span class="line"></span><br><span class="line"><span class="built_in">module</span>.exports = &#123;</span><br><span class="line">    entry: entry,</span><br><span class="line">    output: &#123;</span><br><span class="line">        path: path.join(__dirname,<span class="string">&#x27;dist&#x27;</span>),</span><br><span class="line">        filename: <span class="string">&#x27;[name]_[chunkhash:8].js&#x27;</span></span><br><span class="line">    &#125;,</span><br><span class="line">    ....</span><br><span class="line">    plugins: [</span><br><span class="line">    	...</span><br><span class="line">    ].concat(htmlWebpackPlugins)</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="source-map"><a href="#source-map" class="headerlink" title="source map"></a>source map</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412234031607.png" alt="image-20210412234031607"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412234527649.png" alt="image-20210412234527649"></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210412234753864.png" alt="image-20210412234753864"></p>
<h4 id="提取页面公共资源"><a href="#提取页面公共资源" class="headerlink" title="提取页面公共资源"></a>提取页面公共资源</h4><p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/image-20210413230951156.png" alt="image-20210413230951156"></p>
<h2 id="webpack进阶用法"><a href="#webpack进阶用法" class="headerlink" title="webpack进阶用法"></a>webpack进阶用法</h2><h2 id="编写可维护的webpack构建配置"><a href="#编写可维护的webpack构建配置" class="headerlink" title="编写可维护的webpack构建配置"></a>编写可维护的webpack构建配置</h2><h2 id="原理：通过源码掌握webpack打包原理"><a href="#原理：通过源码掌握webpack打包原理" class="headerlink" title="原理：通过源码掌握webpack打包原理"></a>原理：通过源码掌握webpack打包原理</h2><h2 id="原理：编写Loader和插件"><a href="#原理：编写Loader和插件" class="headerlink" title="原理：编写Loader和插件"></a>原理：编写Loader和插件</h2><h2 id="实战：React全家桶和webpack开发"><a href="#实战：React全家桶和webpack开发" class="headerlink" title="实战：React全家桶和webpack开发"></a>实战：React全家桶和webpack开发</h2></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">mozihao</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://mo_zi_hao.gitee.io/blog/posts/15318/">https://mo_zi_hao.gitee.io/blog/posts/15318/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://mo_zi_hao.gitee.io/blog" target="_blank">mozihao</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/745.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/posts/35506/"><img class="prev-cover" src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/1234.jpg" onerror="onerror=null;src='/blog/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">微信小程序</div></div></a></div><div class="next-post pull-right"><a href="/blog/posts/29998/"><img class="next-cover" src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/745.jpg" onerror="onerror=null;src='/blog/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">webpack4+vue-cli3</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/%E6%B5%B7%E8%B4%BC008.jpg" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">mozihao</div><div class="author-info__description">if you risk nothing,then you risk anthing</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">24</div></a></div><div class="card-info-data-item is-center"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">16</div></a></div><div class="card-info-data-item is-center"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/mo_zi_hao"><i class="iconfont icon-gitee-fill-round"></i><span>我的Gitee</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitee.com/mo_zi_hao" target="_blank" title="Gitee"><i class="fab iconfont icon-gitee-fill-round"></i></a><a class="social-icon" href="https://github.com/mmCrazy" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://blog.csdn.net/xiaomohhh?spm=1001.2101.3001.5343" target="_blank" title="CSDN"><i class="fab iconfont icon-csdn"></i></a><a class="social-icon" href="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/qrcode_for_gh_d35478eda980_430.jpg" target="_blank" title="公众号"><i class="fab iconfont icon-weixingongzhonghao"></i></a><a class="social-icon" href="mailto:747304031@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">如文章中有哪些错漏，欢迎各位前端的大佬与我交流并指正，谢谢!!</br>邮箱：747304031@qq.com</br>公众号：一起写前端bug</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#webpack"><span class="toc-number">1.</span> <span class="toc-text">webpack</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BD%BF%E7%94%A8webpack"><span class="toc-number">2.</span> <span class="toc-text">为什么使用webpack</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#webpack%E5%9F%BA%E7%A1%80%E7%94%A8%E6%B3%95"><span class="toc-number">3.</span> <span class="toc-text">webpack基础用法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#entry%EF%BC%9A"><span class="toc-number">3.1.</span> <span class="toc-text">entry：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ouput"><span class="toc-number">3.2.</span> <span class="toc-text">ouput</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#loader"><span class="toc-number">3.3.</span> <span class="toc-text">loader</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#babel"><span class="toc-number">3.3.1.</span> <span class="toc-text">babel</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#css"><span class="toc-number">3.3.2.</span> <span class="toc-text">css</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%A7%A3%E6%9E%90%E5%9B%BE%E7%89%87%E5%AD%97%E4%BD%93"><span class="toc-number">3.3.3.</span> <span class="toc-text">解析图片字体</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#file-loader"><span class="toc-number">3.3.3.1.</span> <span class="toc-text">file-loader</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#url-loader-%E5%92%8Cfile-loader%E5%B7%AE%E4%B8%8D%E5%A4%9A%EF%BC%8C%E5%86%85%E9%83%A8%E4%B9%9F%E6%98%AF%E7%94%A8%E4%BA%86file-loader"><span class="toc-number">3.3.3.2.</span> <span class="toc-text">url-loader(和file-loader差不多，内部也是用了file-loader)</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#plugin"><span class="toc-number">3.4.</span> <span class="toc-text">plugin</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mode"><span class="toc-number">3.5.</span> <span class="toc-text">mode</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#webpack%E4%B8%AD%E7%9A%84%E6%96%87%E4%BB%B6%E7%9B%91%E5%90%AC"><span class="toc-number">3.6.</span> <span class="toc-text">webpack中的文件监听</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%83%AD%E6%9B%B4%E6%96%B0"><span class="toc-number">3.7.</span> <span class="toc-text">热更新</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E6%8C%87%E7%BA%B9%E7%AD%96%E7%95%A5"><span class="toc-number">3.8.</span> <span class="toc-text">文件指纹策略</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%8E%8B%E7%BC%A9"><span class="toc-number">3.9.</span> <span class="toc-text">代码压缩</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#js%E6%96%87%E4%BB%B6%E7%9A%84%E5%8E%8B%E7%BC%A9"><span class="toc-number">3.9.1.</span> <span class="toc-text">js文件的压缩</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#CSS%E6%96%87%E4%BB%B6%E7%9A%84%E5%8E%8B%E7%BC%A9"><span class="toc-number">3.9.2.</span> <span class="toc-text">CSS文件的压缩</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#html%E6%96%87%E4%BB%B6%E5%8E%8B%E7%BC%A9"><span class="toc-number">3.9.3.</span> <span class="toc-text">html文件压缩</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%89%93%E5%8C%85%E6%96%87%E4%BB%B6%E5%88%A0%E9%99%A4"><span class="toc-number">3.9.4.</span> <span class="toc-text">打包文件删除</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%89%8B%E5%8A%A8%E5%88%A0%E9%99%A4"><span class="toc-number">3.9.4.1.</span> <span class="toc-text">手动删除</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%A0%E9%99%A4"><span class="toc-number">3.9.4.2.</span> <span class="toc-text">使用插件删除</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%87%AA%E5%8A%A8%E8%A1%A5%E5%85%A8css%E5%89%8D%E7%BC%80"><span class="toc-number">3.9.5.</span> <span class="toc-text">自动补全css前缀</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%A7%BB%E5%8A%A8%E7%AB%AFcss-px%E8%87%AA%E5%8A%A8%E8%BD%AC%E6%8D%A2%E6%88%90rem"><span class="toc-number">3.9.6.</span> <span class="toc-text">移动端css px自动转换成rem</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%B5%84%E6%BA%90%E5%86%85%E8%81%94"><span class="toc-number">3.9.7.</span> <span class="toc-text">资源内联</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#css%E5%86%85%E8%81%94"><span class="toc-number">3.9.8.</span> <span class="toc-text">css内联</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%A4%9A%E9%A1%B5%E9%9D%A2%E6%89%93%E5%8C%85"><span class="toc-number">3.9.9.</span> <span class="toc-text">多页面打包</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#source-map"><span class="toc-number">3.9.10.</span> <span class="toc-text">source map</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8F%90%E5%8F%96%E9%A1%B5%E9%9D%A2%E5%85%AC%E5%85%B1%E8%B5%84%E6%BA%90"><span class="toc-number">3.9.11.</span> <span class="toc-text">提取页面公共资源</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#webpack%E8%BF%9B%E9%98%B6%E7%94%A8%E6%B3%95"><span class="toc-number">4.</span> <span class="toc-text">webpack进阶用法</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E5%86%99%E5%8F%AF%E7%BB%B4%E6%8A%A4%E7%9A%84webpack%E6%9E%84%E5%BB%BA%E9%85%8D%E7%BD%AE"><span class="toc-number">5.</span> <span class="toc-text">编写可维护的webpack构建配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8E%9F%E7%90%86%EF%BC%9A%E9%80%9A%E8%BF%87%E6%BA%90%E7%A0%81%E6%8E%8C%E6%8F%A1webpack%E6%89%93%E5%8C%85%E5%8E%9F%E7%90%86"><span class="toc-number">6.</span> <span class="toc-text">原理：通过源码掌握webpack打包原理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8E%9F%E7%90%86%EF%BC%9A%E7%BC%96%E5%86%99Loader%E5%92%8C%E6%8F%92%E4%BB%B6"><span class="toc-number">7.</span> <span class="toc-text">原理：编写Loader和插件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9E%E6%88%98%EF%BC%9AReact%E5%85%A8%E5%AE%B6%E6%A1%B6%E5%92%8Cwebpack%E5%BC%80%E5%8F%91"><span class="toc-number">8.</span> <span class="toc-text">实战：React全家桶和webpack开发</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/1/" title="无题"><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/%E6%B5%B7%E8%B4%BC4.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="无题"/></a><div class="content"><a class="title" href="/blog/posts/1/" title="无题">无题</a><time datetime="2022-06-05T05:20:17.974Z" title="发表于 2022-06-05 13:20:17">2022-06-05</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/36549/" title="编写可维护的JavaScript (代码习惯)"><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/%E6%B5%B7%E8%B4%BC4.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="编写可维护的JavaScript (代码习惯)"/></a><div class="content"><a class="title" href="/blog/posts/36549/" title="编写可维护的JavaScript (代码习惯)">编写可维护的JavaScript (代码习惯)</a><time datetime="2022-03-19T03:12:42.624Z" title="发表于 2022-03-19 11:12:42">2022-03-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/23125/" title="gitlab-cicd"><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/745.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="gitlab-cicd"/></a><div class="content"><a class="title" href="/blog/posts/23125/" title="gitlab-cicd">gitlab-cicd</a><time datetime="2021-12-20T14:00:59.661Z" title="发表于 2021-12-20 22:00:59">2021-12-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/449/" title="前端js基础"><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/26&amp;gp=0.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="前端js基础"/></a><div class="content"><a class="title" href="/blog/posts/449/" title="前端js基础">前端js基础</a><time datetime="2021-08-29T15:22:14.600Z" title="发表于 2021-08-29 23:22:14">2021-08-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/35506/" title="微信小程序"><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/1234.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="微信小程序"/></a><div class="content"><a class="title" href="/blog/posts/35506/" title="微信小程序">微信小程序</a><time datetime="2021-08-29T15:22:14.600Z" title="发表于 2021-08-29 23:22:14">2021-08-29</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By mozihao</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="/blog/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/blog/js/search/local-search.js"></script><div class="js-pjax"></div><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>